package cn.sfrog.project.biz.admin.controller;

import cn.sfrog.common.annotation.Log;
import cn.sfrog.common.annotation.RepeatSubmit;
import cn.sfrog.common.core.controller.BaseController;
import cn.sfrog.common.core.domain.AjaxResult;
import cn.sfrog.common.core.page.TableDataInfo;
import cn.sfrog.common.enums.BusinessType;
import cn.sfrog.common.utils.poi.ExcelUtil;
import cn.sfrog.project.biz.admin.domain.vo.BizUserIdentityAuditRecordFormVO;
import cn.sfrog.project.biz.admin.domain.vo.BizUserIdentityAuditRecordQueryVO;
import cn.sfrog.project.biz.admin.domain.vo.BizUserIdentityAuditRecordVO;
import cn.sfrog.project.biz.admin.service.IBizUserIdentityAuditRecordService;
import cn.sfrog.system.domain.vo.BizStatusChangeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

@Api(tags = "用户身份审核记录接口")
@RestController
@RequestMapping("/biz/identityAuditRecord")
public class BizUserIdentityAuditRecordController extends BaseController {
    @Resource
    private IBizUserIdentityAuditRecordService bizUserIdentityAuditRecordService;

    /**
     * 查询用户身份审核记录列表
     */
    @ApiOperation("查询列表")
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizUserIdentityAuditRecordQueryVO queryVO) {
        startPage();
        List<BizUserIdentityAuditRecordVO> list = bizUserIdentityAuditRecordService.selectBizUserIdentityAuditRecordList(queryVO);
        return getDataTable(list);
    }

    /**
     * 导出用户身份审核记录列表
     */
    @ApiOperation("导出")
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:export')")
    @Log(title = "用户身份审核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizUserIdentityAuditRecordQueryVO query) {
        List<BizUserIdentityAuditRecordVO> list = bizUserIdentityAuditRecordService.selectBizUserIdentityAuditRecordList(query);
        ExcelUtil<BizUserIdentityAuditRecordVO> util = new ExcelUtil<BizUserIdentityAuditRecordVO>(BizUserIdentityAuditRecordVO.class);
        util.exportExcel(response, list, "用户身份审核记录数据");
    }

    /**
     * 获取用户身份审核记录详细信息
     */
    @ApiOperation("获取详情")
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bizUserIdentityAuditRecordService.selectBizUserIdentityAuditRecordById(id));
    }

    /**
     * 新增用户身份审核记录
     */
    @ApiOperation("新增")
    @RepeatSubmit
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:add')")
    @Log(title = "用户身份审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizUserIdentityAuditRecordFormVO form) {
        return toAjax(bizUserIdentityAuditRecordService.insertBizUserIdentityAuditRecord(form));
    }

    /**
     * 修改用户身份审核记录
     */
    @ApiOperation("修改")
    @RepeatSubmit
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:edit')")
    @Log(title = "用户身份审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizUserIdentityAuditRecordFormVO form) {
        return toAjax(bizUserIdentityAuditRecordService.updateBizUserIdentityAuditRecord(form));
    }

    /**
     * 删除用户身份审核记录
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:remove')")
    @Log(title = "用户身份审核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bizUserIdentityAuditRecordService.deleteBizUserIdentityAuditRecordByIds(ids));
    }

    /**
     * 更改状态用户身份审核记录
     */
    @ApiOperation("更改状态")
    @PreAuthorize("@ss.hasPermi('biz:identityAuditRecord:changeStatus')")
    @Log(title = "用户身份审核记录", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody @Valid BizStatusChangeVO vo) {
        return AjaxResult.success(bizUserIdentityAuditRecordService.changeStatus(vo));
    }
}
